package com.allwees.core.common.util;

import java.util.UUID;

public class UuidUtil {
	public static synchronized String generate() {
		return generate(false);
	}

	public static String generate(boolean withSeparator) {
		String uuid = UUID.randomUUID().toString();
		if(!withSeparator) {
			uuid = uuid.replace("-", "");
		}
		return uuid;
	}

	public static String generate(String str) {
		return generate(str, false);
	}

	public static String generate(String str,boolean withSeparator) {
		String uuid = UUID.nameUUIDFromBytes(str.getBytes()).toString();
		if(!withSeparator) {
			uuid = uuid.replace("-", "");
		}
		return uuid;
	}
}
